package com.example.beryl.http;
import com.example.beryl.entity.Action;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class Net_productReport {
    private ArrayList<String> arrayList = new ArrayList<String>();
    private ArrayList<String> brrayList = new ArrayList<String>();
    private ArrayList<String> crrayList = new ArrayList<String>();
    private Net_method soap2 = new Net_method();

    //private static String URL ="ProductReports.asmx";//服务器地址
    private static String URL ="ProductReports.asmx";//调试地址

    public List<String> CS_CommonMethod(String what, String para)
    {
        List<String> list = new ArrayList<>();
        try
        {
            switch (what)
            {
                case Action.action.getProductReport:
                    list = getBarCode(para);
                    break;
                case Action.action.getProductReportQuery:
                    list = selectQueryData(para);
                    break;
//                case Action.action.ckeckPRSummitData://检查开工记录提交数据
//                    list = checkSummitData(para);
                    //break;
                case Action.action.PRSummitData://开工记录正常提交数据
                    list = SummitData(para);
                    break;
                case Action.action.getTimeBC://根据时间获取班次
                    list = getTimeBC(para);
                    break;
                case Action.action.UnProductData://不良品提交
                    list = SummitUnProduct(para);
                    break;
//                case Action.action.OutNumSummit://开工记录超出数量提交数据
//                    list = OutNumSummit(para);
//                    break;
//                case Action.action.NotTopProcessSummit://开工记录上工序未报工提交数据
//                    list = NotTopProcessSummit(para);
//                    break;
//                case Action.action.TopProcessOutSummit://开工记录上工序未报工数量超出提交数据
//                    list = TopProcessOutSummit(para);
                   // break;
            }

        }catch (Exception e)
        {

        }
        return list;
    }

    //获取流传单信息
    public List<String> getBarCode(String barcode) {
        // List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("barcode");
        brrayList.add(barcode);
        try
        {
            crrayList = soap2.SummitData("selectBarCode", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    public List<String> selectQueryData(String barcode) {
        // List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("para");
        brrayList.add(barcode);
        try
        {
            crrayList = soap2.SummitData("selectQueryData", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    public List<String> checkSummitData(String barcode) {
        // List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("para");
        brrayList.add(barcode);
        try
        {
            crrayList = soap2.SummitData("summitDataCheck", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    public List<String> SummitData(String barcode) {
        // List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("para");
        brrayList.add(barcode);
        try
        {
            crrayList = soap2.SummitData("PRSummitData", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }
    public List<String> OutNumSummit(String barcode) {
        // List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("para");
        brrayList.add(barcode);
        try
        {
            crrayList = soap2.SummitData("OutNumSummit", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    public List<String> NotTopProcessSummit(String barcode) {
        // List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("para");
        brrayList.add(barcode);
        try
        {
            crrayList = soap2.SummitData("NotTopProcessSummit", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    public List<String> TopProcessOutSummit(String barcode) {
        // List<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("para");
        brrayList.add(barcode);
        try
        {
            crrayList = soap2.SummitData("TopProcessOutSummit", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    public List<String> getTimeBC(String para)
    {
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("para");
        brrayList.add(para);
        try
        {
            crrayList = soap2.SummitData("getTimeBC", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }

    public List<String> SummitUnProduct(String para)
    {
        ArrayList<String> list = new ArrayList<String>();
        arrayList.clear();
        brrayList.clear();
        //crrayList.clear();
        arrayList.add("para");
        brrayList.add(para);
        try
        {
            crrayList = soap2.SummitData("SummitUnProduct", arrayList, brrayList,URL);
            if (crrayList == null)
            {
                //对象销毁
                crrayList.removeIf(Objects::isNull);
                return list;
            }
            else
            {
                list = crrayList;
            }
        }
        catch (Exception e)
        {
            return null;
        }
        return list;
    }
}
